// pages/common/agreement/index.js
import Config from "../../../main.config";
import {getStorageSync} from "../../../utils/Storage";
Page({

    /**
     * 页面的初始数据
     */
    data: {
        showService: false,
        showPrivacy: false,
        content: "",
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getContent(options.type)
    },

    /*
    * 协议展示
    * 根据type值不同展示不同协议
    * type === service 服务协议
    * type === privacy 隐私协议
    * */
    getContent: function (type) {
        let agreementDetail = "";
        if (type === "service") {
            wx.setNavigationBarTitle({title: "服务协议"});
            agreementDetail = decodeURIComponent(getStorageSync(Config.storage.agreement + ".service") || "");
            this.setData({
                showService: true,
                content: agreementDetail
            })
        } else {
            wx.setNavigationBarTitle({title: "隐私协议"});
            agreementDetail = decodeURIComponent(getStorageSync(Config.storage.agreement + ".privacy") || "");
            this.setData({
                showPrivacy: true,
                content: agreementDetail
            })
        }
    }

})